import 'package:flutter/material.dart';
import './collapsible_sidebar.dart';
import '../../../core/platform/platform_detector.dart';

/// 自适应导航栏组件，根据平台调整样式
class AdaptiveNavigation extends StatelessWidget {
  final int selectedIndex;
  final ValueChanged<int> onDestinationSelected;
  final List<NavigationDestination> destinations;
  final List<Widget> pages;

  const AdaptiveNavigation({
    super.key,
    required this.selectedIndex,
    required this.onDestinationSelected,
    required this.destinations,
    required this.pages,
  });

  @override
  Widget build(BuildContext context) {
    // 桌面和Web平台使用可折叠侧边栏导航
    if (PlatformDetector.isDesktop() || PlatformDetector.isWeb()) {
      return CollapsibleSidebar(
        selectedIndex: selectedIndex,
        onDestinationSelected: onDestinationSelected,
        destinations: destinations,
        pages: pages,
      );
    } else {
      // 移动平台使用底部导航栏
      return Scaffold(
        body: pages[selectedIndex],
        bottomNavigationBar: NavigationBar(
          selectedIndex: selectedIndex,
          onDestinationSelected: onDestinationSelected,
          destinations: destinations,
        ),
      );
    }
  }
}
